home *** CD-ROM | disk | FTP | other *** search
/ Aminet 31 / Aminet 31 (1999)(Schatztruhe)[!][Jun 1999].iso / Aminet / dev / gui / gtlayout.lha / Source / LT_NewMenuTemplate.c < prev    next >
C/C++ Source or Header  |  1998-09-09  |  4KB  |  135 lines

  1. /*
  2. **    GadTools layout toolkit
  3. **
  4. **    Copyright © 1993-1998 by Olaf `Olsen' Barthel
  5. **        Freely distributable.
  6. **
  7. **    :ts=4
  8. */
  9.  
  10. #ifndef _GTLAYOUT_GLOBAL_H
  11. #include "gtlayout_global.h"
  12. #endif
  13.  
  14. /*****************************************************************************/
  15.  
  16. #include <dos/dos.h>    /* For AmigaDOS error definitions */
  17.  
  18. /*****************************************************************************/
  19.  
  20. #include "Assert.h"
  21.  
  22. /*****************************************************************************/
  23.  
  24. #ifdef DO_MENUS    /* Support code */
  25.  
  26. /****** gtlayout.library/LT_NewMenuTemplate ******************************************
  27. *
  28. *   NAME
  29. *    LT_NewMenuTemplate -- Allocate and layout menu items (V11)
  30. *
  31. *   SYNOPSIS
  32. *    Menu = LT_NewMenuTemplate(Screen,TextAttr,AmigaGlyph,CheckmarkGlyph,
  33. *     D0                         A0      A1        A2           A3
  34. *
  35. *                              Error,MenuTemplate);
  36. *                                D0      D1
  37. *
  38. *    struct Menu *LT_NewMenuTemplate(struct Screen *,struct TextAttr *,
  39. *                                    struct Image *,struct Image *,
  40. *                                    LONG *,struct NewMenu *);
  41. *
  42. *   FUNCTION
  43. *    Allocates Menus and MenuItems similar to LT_LayoutMenus().
  44. *
  45. *    As of v18 this routine will validate menu mutual exclusion
  46. *    information.
  47. *
  48. *   INPUTS
  49. *    Screen - Pointer to the screen the menu will appear on. This
  50. *        parameter is required and must not be omitted.
  51. *
  52. *    TextAttr - Pointer to the TextAttr that should be used to
  53. *        layout the menus. If this parameter is omitted,
  54. *        Screen->Font will be used instead.
  55. *
  56. *    AmigaGlyph - Pointer to the Image to use as the Amiga glyph.
  57. *        This parameter may be omitted.
  58. *
  59. *            NOTE: Ignored by intuition.library v37 and below.
  60. *
  61. *    CheckmarkGlyph - Pointer to the Image to use as the checkmark
  62. *        glyph. This parameter may be omitted.
  63. *
  64. *    Error - Pointer to receive error code in case the menu
  65. *        creation or layout process fails. This parameter
  66. *        may be omitted.
  67. *
  68. *    MenuTemplate - Pointer to a series of NewMenu structures,
  69. *        just as you would pass to
  70. *        gtlayout.library/LT_LayoutMenuA.
  71. *
  72. *   RESULT
  73. *    Menu - Pointer to Menu structure, ready to pass to
  74. *        SetMenuStrip(), NULL on failure.
  75. *
  76. *   NOTES
  77. *    The menu created by this function cannot be used with the
  78. *    routines LT_MenuControlTagList, LT_FindMenuCommand and
  79. *    LT_GetMenuItem.
  80. *
  81. *    You may freely add, remove, spindle & mutilate the contents of the
  82. *    menu strip created, just don't trash or disconnect the base menu
  83. *    entry this routine creates as all menu memory tracking data is
  84. *    connected with it.
  85. *
  86. *   SEE ALSO
  87. *    gtlayout.library/LT_DisposeMenu
  88. *    gtlayout.library/LT_LayoutMenuA
  89. *    gtlayout.library/LT_NewMenuTagList
  90. *    intuition.library/SetMenuStrip
  91. *
  92. ******************************************************************************
  93. *
  94. */
  95.  
  96. struct Menu * LIBENT
  97. LT_NewMenuTemplate(REG(a0) struct Screen *Screen,REG(a1) struct TextAttr *TextAttr,REG(a2) struct Image *AmigaGlyph,REG(a3) struct Image *CheckGlyph,REG(d0) LONG *ErrorPtr,REG(d1) struct NewMenu *MenuTemplate)
  98. {
  99.     LONG Error;
  100.  
  101.     if(ErrorPtr)
  102.         *ErrorPtr = 0;
  103.  
  104.     if(MenuTemplate)
  105.     {
  106.         RootMenu *Root;
  107.  
  108.         if(Root = LTP_NewMenu(Screen,TextAttr,AmigaGlyph,CheckGlyph,&Error))
  109.         {
  110.                 // Create the menu
  111.  
  112.             if(LTP_CreateMenuTemplate(Root,&Error,MenuTemplate))
  113.             {
  114.                     // Do the layout
  115.  
  116.                 if(LTP_LayoutMenu(Root,2,2))
  117.                     return(&Root->Menu);
  118.                 else
  119.                     Error = ERROR_DISK_FULL;
  120.             }
  121.  
  122.             LT_DisposeMenu(&Root->Menu);
  123.         }
  124.     }
  125.     else
  126.         Error = ERROR_REQUIRED_ARG_MISSING;
  127.  
  128.     if(ErrorPtr)
  129.         *ErrorPtr = Error;
  130.  
  131.     return(NULL);
  132. }
  133.  
  134. #endif    /* DO_MENUS */
  135.